home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
boe.pres.k12.wv.us
/
boe.pres.k12.wv.us.zip
/
boe.pres.k12.wv.us
/
Utilities
/
Xerox Workcentre 5335
/
Windows Scan
/
64-bit_x64
/
Russian
/
cpsimage.cab
/
data
/
sys
/
XIPRunCallback.elf
< prev
next >
Wrap
Text File
|
2009-04-23
|
5KB
|
127 lines
/* $Id: XIPRunCallback.elf,v 1.1 2008/03/12 16:55:19 campanel Exp $ */
/* This file contains script to parse xml that contains a script (either by
** name or the actual script) and parameters. The script begins near the end
** of the file. Currently this supports two schemas that define the XML
** document to parse.
*/
#load "sys/xipxml.elf";
/*****************************************************************************/
/*
** This class implements the XML serializer and callback for SummonXIP
*/
private CLASS XIPRunCallback
{
METHOD setVocal (BOOLEAN setTo) {
this.isVocal = setTo;
}
METHOD appendData( STRING ident, STRING datatype, OBJECT dObj )
{
if (this.isVocal == TRUE) {
print "XIPRunCallback.appendData";
print " Data name: "+ident+" has type of "+datatype+". Value is:";
print dObj;
}
this.objs.insert( entry: this.nextIndex, obj: dObj );
this.ids.insert( entry: this.nextIndex, obj: ident );
this.dtype.insert( entry: this.nextIndex, obj: datatype );
this.nextIndex = this.nextIndex+1;
}
METHOD clearData()
{
if (this.isVocal == TRUE) print "XIPRunCallback.ClearData - clearing callback data";
this.objs.clear();
this.ids.clear();
this.dtype.clear();
this.nextIndex = 0;
}
METHOD invoke ()
{
STRING callXML;
if (this.isVocal == TRUE) {
print "XIPRunCallback.invoke";
print "The value of the callback is ",this.cbFunction;
}
callXML = this.makeCallbackXML();
if (this.callData) this.cInvoke( cData: callXML );
}
/*****************************************************************************
******************** Lots of Private Methods ******************************
*****************************************************************************/
private METHOD makeCallbackXML( ) RETURNS ( STRING cbXml ) {
if (this.isVocal == TRUE) print "XIPRunCallback:makeCallbackXML";
XmlDocumentBuilder cbdb;
XmlDocument cbdoc = cbdb.newDocument();
XmlElement cbroot = cbdoc.createElement( name: "RunXIP" );
cbdoc.setDocumentElement( node: cbroot );
XmlElement cbout = cbdoc.createElement( name: "Callback" );
cbroot.appendChild ( node: cbout );
INTEGER icnt = this.nextIndex;
INTEGER i;
STRING rtype;
STRING cname;
OBJECT cObj;
for ( i=0; i<icnt; i++ )
{
cname = this.ids.ref( entry: i );
cObj = this.objs.ref( entry: i );
rtype = this.dtype.ref( entry: i );
this.addCallbackValXML( xmlDoc: cbdoc, outEle: cbout,
obj: cObj, name: cname, datatype: rtype );
}
if (this.isVocal == TRUE) {
print "Callback Document is:";
print cbdoc.dumpString( format: 1 );
}
cbXml = cbdoc.dumpString( format: 0 );
}
private METHOD addCallbackValXML( XmlDocument xmlDoc, XmlElement outEle, OBJECT obj,
STRING name, STRING datatype )
{
XmlAttr rtAttr;
XmlElement rtelm = xmlDoc.createElement( name: "CallbackVal" );
XmlElement valName = xmlDoc.createElement( name: "Name" );
XmlElement valVal = xmlDoc.createElement( name: "Value" );
STRING objAsStr = obj;
/* Add the ArgType attribute to the ReturnVal element */
rtAttr = xmlDoc.createAttribute(name: "ArgType");
rtAttr.setValue( value: datatype );
rtelm.setAttributeNode( node: rtAttr );
/* Add a child element that contains the Val's name */
valName.setNodeValue( value: name );
rtelm.appendChild ( node: valName );
/* Add a child element that contains the actual value */
valVal.setNodeValue( value: objAsStr );
rtelm.appendChild ( node: valVal );
/* put the new element (ReturnVal) into the Output element */
outEle.appendChild ( node: rtelm );
}
private METHOD cInvoke( STRING cData ) NATIVE "SummonXIPCallback@xipsup";
/*****************************************************************************
******************** Internal Data Fields ******************************
*****************************************************************************/
STRING callData = "<DefaultReturn></DefaultReturn>";
BOOLEAN isVocal = FALSE;
LIST objs;
LIST ids;
LIST dtype;
INTEGER nextIndex = 0;
VOID cbFunction;
}